package lottery;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * @author liuding,2012-3-26
 *投注记录
 *返点金额=投注总额*返点比例
 * $LastChangedDate$
 * $Author$ 
 */
@Table
@Entity
public class BetRecord
{
    private int id;
    private int ownerId; //投注人id
    private String ownerName; //投注人用户名
    private String orderId;  //单号
    private int lotteryId;  //彩种ID
    private String lotteryName; //彩种名称
    private int betFatherId;  //投注方式ID （N星、大小单双、不定胆等）
    private String betFatherName;
    private int betId;  //投注类型ID （后三直选复式、组三、组六等）
    private String betName;
    private String number;  //投注号码
    private String openRewardNumber; //开奖号码
    private String betBit;  //投注的位置: 1,0,1,0,1,0 一共N个位置，以","隔开，1则为已投位，0为未投
    private String numberId;  //投注期号
    private int count;  //注数
    private double singleAmount; //单注金额
    private float returnPoint;  //所选返点
    private double reward;  //奖金
    private double payUnit;  //中奖派发：800*单注金额 
    private int isPay;  // 是否派奖 0-否|1-是
    private int isWin;  //  是否赢 0-否|1-是
    private int winCount; //中奖注数
    private double winAmount; //中奖总金额=中奖注数*每注单价*赔率
    private Date createDate;
    private int isCancel; //是否撤单 0-正常|1-撤单
    private int isChase; //是否追号 0-否
    private int isWinStop; //是否中奖后停止追号 0-否|1-是
    private int isUnion; //是否合买 0-否|1-是
    
    /**获取投注位置
     * @return
     */
    @Transient
    public String getBitNote(){
    	StringBuffer bitNote = new StringBuffer();
    	if(betName == null){
    		return "";
    	}
    	if((betName.contains("复式") || betName.contains("定位胆")
    			|| betName.contains("不定位")) && !betName.contains("二星组选复式")){
    		return "";
    	}
    	if(betBit != null){
    		String bitArr[] = betBit.split(",");
    		if(bitArr[0].equals("1"))
    			bitNote.append("万");
    		if(bitArr[1].equals("1"))
    			bitNote.append("千");
    		if(bitArr[2].equals("1"))
    			bitNote.append("百");
    		if(bitArr[3].equals("1"))
    			bitNote.append("十");
    		if(bitArr[4].equals("1"))
    			bitNote.append("个");
    	}
    	return bitNote.toString();
    }
    
    public int getCount()
    {
        return count;
    }
    public void setCount(int count)
    {
        this.count = count;
    }
    @Id
    @GeneratedValue
    public int getId()
    {
        return id;
    }
    public void setId(int id)
    {
        this.id = id;
    }
    public int getLotteryId()
    {
        return lotteryId;
    }
    public void setLotteryId(int lotteryId)
    {
        this.lotteryId = lotteryId;
    }
    public String getNumber()
    {
        return number;
    }
    public void setNumber(String number)
    {
        this.number = number;
    }
    public String getOrderId()
    {
        return orderId;
    }
    public void setOrderId(String orderId)
    {
        this.orderId = orderId;
    }
    public double getSingleAmount()
    {
        return singleAmount;
    }
    public void setSingleAmount(double singleAmount)
    {
        this.singleAmount = singleAmount;
    }
    @Column(length=30)
	public String getLotteryName() {
		return lotteryName;
	}
	public void setLotteryName(String lotteryName) {
		this.lotteryName = lotteryName;
	}
	public int getBetFatherId() {
		return betFatherId;
	}
	public void setBetFatherId(int betFatherId) {
		this.betFatherId = betFatherId;
	}
	@Column(length=30)
	public String getBetFatherName() {
		return betFatherName;
	}
	public void setBetFatherName(String betFatherName) {
		this.betFatherName = betFatherName;
	}
	public int getBetId() {
		return betId;
	}
	public void setBetId(int betId) {
		this.betId = betId;
	}
	@Column(length=30)
	public String getBetName() {
		return betName;
	}
	public void setBetName(String betName) {
		this.betName = betName;
	}
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCreateDate()
    {
        return createDate;
    }
    public void setCreateDate(Date createDate)
    {
        this.createDate = createDate;
    }
   
    public int getIsPay()
    {
        return isPay;
    }
    public void setIsPay(int isPay)
    {
        this.isPay = isPay;
    }
    public int getIsWin()
    {
        return isWin;
    }
    public void setIsWin(int isWin)
    {
        this.isWin = isWin;
    }
    public float getReturnPoint()
    {
        return returnPoint;
    }
    public void setReturnPoint(float returnPoint)
    {
        this.returnPoint = returnPoint;
    }
    public double getWinAmount()
    {
        return winAmount;
    }
    public void setWinAmount(double winAmount)
    {
        this.winAmount = winAmount;
    }
    public int getWinCount()
    {
        return winCount;
    }
    public void setWinCount(int winCount)
    {
        this.winCount = winCount;
    }

	public int getOwnerId() {
		return ownerId;
	}
	public void setOwnerId(int ownerId) {
		this.ownerId = ownerId;
	}
	@Column(length=30)
	public String getOwnerName() {
		return ownerName;
	}
	public void setOwnerName(String ownerName) {
		this.ownerName = ownerName;
	}
    @Column(length=60)
    public String getNumberId()
    {
        return numberId;
    }
    public void setNumberId(String numberId)
    {
        this.numberId = numberId;
    }
    @Column(length=30)
    public String getBetBit()
    {
        return betBit;
    }
    public void setBetBit(String betBit)
    {
        this.betBit = betBit;
    }
	public void setOpenRewardNumber(String openRewardNumber) {
		this.openRewardNumber = openRewardNumber;
	}
	@Column(length=50)
	public String getOpenRewardNumber() {
		return openRewardNumber;
	}
    public int getIsCancel()
    {
        return isCancel;
    }
    public void setIsCancel(int isCancel)
    {
        this.isCancel = isCancel;
    }
	public void setIsChase(int isChase) {
		this.isChase = isChase;
	}
	public int getIsChase() {
		return isChase;
	}
	public void setReward(double reward) {
		this.reward = reward;
	}
	public double getReward() {
		return reward;
	}
	public void setPayUnit(double payUnit) {
		this.payUnit = payUnit;
	}
	public double getPayUnit() {
		return payUnit;
	}

	public void setIsWinStop(int isWinStop) {
		this.isWinStop = isWinStop;
	}

	public int getIsWinStop() {
		return isWinStop;
	}

	public void setIsUnion(int isUnion) {
		this.isUnion = isUnion;
	}

	public int getIsUnion() {
		return isUnion;
	}
    
}
